﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

//用户注册的实体类
public class User
{
    public int id;
    public string username;
    public string nickname;
    public string password;
}

public class Error
{
    public int code;
    public Error()
    {

    }
    public Error(int value)
    {
        code = value;
    }
}

public class TestLogin : MonoBehaviour {

    public InputField userText;
    public InputField passText;
    public InputField nickText;

    public Button registBtn;
    public Button loginBtn;

	void Start () {

        registBtn.onClick.AddListener(OnRegist);
        loginBtn.onClick.AddListener(OnLogin);

    }
	
    void OnRegist()
    {
        User user = new User();
        user.username = userText.text;
        user.password = passText.text;
        user.nickname = nickText.text;

        NetworkManager.Instance.SendMessage(Protocol.UserRegister_CMD,JsonUtility.ToJson(user));

    }
    void OnLogin()
    {
        User user = new User();
        user.username = userText.text;
        user.password = passText.text;
        user.nickname = nickText.text;

        NetworkManager.Instance.SendMessage(Protocol.UserLogin_CMD, JsonUtility.ToJson(user));
    }
}
